package com.hzit.mmcb.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;



/**
 * 类名：
 * 作者：WF
 * 功能：
 */
// @Configuration
public class MyWebConfig {

    @Bean
    public CorsFilter corsWebFilter(){
        UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
        CorsConfiguration config = new CorsConfiguration();
        config.setAllowCredentials(true);
        config.addAllowedOrigin("*");
        config.addAllowedMethod("*");
        config.addAllowedHeader("*");
        configSource.registerCorsConfiguration("/**",config);
        CorsFilter corsWebFilter = new CorsFilter(configSource);
        return corsWebFilter;
    }
}